<?php

namespace App\Models\Page;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class AppagePaneldata
 * @package App\Models\Page
 * @version July 19, 2018, 2:34 pm CST
 *
 * @property \App\Models\Page\Apppage apppage
 * @property \App\Models\Page\Paneltpl paneltpl
 * @property \App\Models\Page\Data data
 * @property integer apppage_id
 * @property string area
 * @property integer paneltpl_id
 * @property integer data_id
 * @property integer resource_data_id
 * @property string name
 * @property string title
 * @property string subtitle
 * @property string img
 * @property string param
 */
class AppagePaneldata extends Model
{
    use SoftDeletes;


    public $table = 'appage_paneldatas';
    

    protected $dates = ['deleted_at'];


    public $fillable = [
        'apppage_id',
        'area',
        'paneltpl_id',
        'data_id',
        'resource_data_id',
        'name',
        'title',
        'subtitle',
        'img',
        'param'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'apppage_id' => 'integer',
        'area' => 'string',
        'paneltpl_id' => 'integer',
        'data_id' => 'integer',
        'resource_data_id' => 'integer',
        'name' => 'string',
        'title' => 'string',
        'subtitle' => 'string',
        'img' => 'string',
        'param' => 'string'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'area' => 'required|max:100'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function apppage()
    {
        return $this->hasOne(\App\Models\Application\Apppage::class, 'id', 'apppage_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function paneltpl()
    {
        return $this->hasOne(\App\Models\Application\Paneltpl::class, 'id', 'paneltpl_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function data()
    {
        return $this->hasOne(\App\Models\Entity\Column\Data::class, 'id', 'data_id');
    }
}
